﻿using BCDto.OA.WorkflowActive.WorkflowActivity;
using BCDto.TMS.Agent.AgentBusiness;
using BCService.Sim.Agent.Agent;
using BCTMSRESTful.Configs;
using BCTMSRESTful.Controllers.Management;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.Management.Agent
{
    /// <summary>
    /// 代理商配置
    /// </summary>
    [ApiExplorerSettings(GroupName = "Admin")]
    [Route("api/v1/sim/[controller]")]
    public class AgentController : ManagementBaseController
    {
        private readonly IAgentBusinessService agentBusinessService;

        public AgentController(IAgentBusinessService agentBusinessService)
        {
            this.agentBusinessService = agentBusinessService;
        }

        /// <summary>
        /// 发起开通下级代理申请
        /// </summary>
        /// <param name="requestDto">代理商区域添加模型信息</param>
        /// <response code="201">添加代理商区域记录</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加代理商区域记录")]
        [ProducesResponseType(typeof(WorkflowActivityDto), 201)]
        public IActionResult Post([FromBody] AgentBusinessRequestDto requestDto)
        {
            var result = this.agentBusinessService.ApplicationOpenChildAgent(this.Admin, requestDto);
            return StatusCode((int)HttpStatusCode.Created, result);
        }

        /// <summary>
        /// 修改代理商信息
        /// </summary>
        /// <param name="modifyDto">代理商信息修改模型</param>
        /// <response code="200">修改代理商信息</response>
        /// <returns></returns>
        [HttpPut("[action]")]
        [Log("修改代理商信息")]
        [ProducesResponseType(typeof(WorkflowActivityDto), 200)]
        public IActionResult ModifyAgentInfo([FromBody] AgentBusinessModifyDto modifyDto)
        {
            var result = this.agentBusinessService.ApplicationModifWyAgentInfo(this.Admin, modifyDto);
            return StatusCode((int)HttpStatusCode.Created, result);
        }
    }
}
